searchenginemodel: finalize search results
authorPierre Ossman <ossman@cendio.se>
Mon, 4 Oct 2021 07:23:39 +0000 (09:23 +0200)
committerPierre Ossman <ossman@cendio.se>
Mon, 4 Oct 2021 07:23:39 +0000 (09:23 +0200)
It is necessary to signal the search engine that we are finished and
that we found something for it to reliably show the results. It would
sometimes work anyway since it is sufficient if any backend signals
completion. However if GtkSearchEngineModel was the only backend
returning results then things would break.

gtk/gtksearchenginemodel.c

index e4dc7ad004ad4cc5f8cb963957cd92d2afce0ae0..83ea00bdb06fc4c8b3f3267edfe69f121a295977 100644 (file)
@@ -81,6 +81,7 @@ do_search (gpointer data)
   GtkSearchEngineModel *model = data;
   GtkTreeIter iter;
   GList *hits = NULL;
+  gboolean got_results = FALSE;
 
   if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model->model), &iter))
     {
@@ -107,11 +108,14 @@ do_search (gpointer data)
         {
           _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
           g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
+          got_results = TRUE;
         }
     }
 
   model->idle = 0;
 
+  _gtk_search_engine_finished (GTK_SEARCH_ENGINE (model), got_results);
+
   return G_SOURCE_REMOVE;
 }